package com.neuedu.config;

import com.neuedu.common.ResultJson;
import com.neuedu.exception.NeueduException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author LiYang
 * @desc
 * @date 2024/11/6 9:13
 */
@RestControllerAdvice
public class DefaultException {
    @ExceptionHandler
    public ResultJson defaultExceptionHandler(Exception ex) {// 统一异常处理
        ex.printStackTrace();
        if (ex instanceof NeueduException){ // 返回控制台
            return ResultJson.failed(ex.getMessage());
        }
        return ResultJson.failed("系统异常");
    }
}
